﻿namespace MicroCloud.Audit.Database
{
    /// <summary>
    /// 审计实体属性信息数据实体映射配置
    /// </summary>
    public class AuditPropertyConfiguration : EntityTypeConfigurationBase<AuditProperty, long>
    {
        /// <summary>
        /// 重写以实现实体类型各个属性的数据库配置
        /// </summary>
        /// <param name="builder">实体类型创建器</param>
        public override void Configuration(EntityTypeBuilder<AuditProperty> builder)
        {
            builder.HasIndex(m => m.AuditEntityId).SetIndex("AuditEntityId");

            builder.HasOne(m => m.AuditEntity).WithMany(n => n.Properties).HasForeignKey(m => m.AuditEntityId).SetForeignKey("AuditEntityId");

            ConfigurationAppend(builder);
        }
    }
}
